//
//  AllenMyMessageHeaderView.m
//  自做商城项目
//
//  Created by allenL on 2017/6/21.
//  Copyright © 2017年 tam. All rights reserved.
//

#import "AllenMyMessageHeaderView.h"

@interface AllenMyMessageHeaderView()
@property (strong , nonatomic) UIImageView *headBackImage;
@property (strong ,nonatomic) UIButton *loginBtn;
@property (strong ,nonatomic) UIButton *landingBtn;

@end

@implementation AllenMyMessageHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.headBackImage];
        [self addSubview:self.loginBtn];
        [self addSubview: self.landingBtn];
    }
    return self;
}

-(void)layoutSubviews{
    __weak typeof (self) weakSelf = self;
    [_headBackImage mas_makeConstraints:^(MASConstraintMaker *make){
        make.edges.equalTo(weakSelf);
    }];
    
    [_loginBtn mas_makeConstraints:^(MASConstraintMaker *make){
        make.centerX.equalTo(weakSelf.mas_centerX).offset(60);
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(45, 23));
    }];
    [_landingBtn mas_makeConstraints:^(MASConstraintMaker *make){
        make.centerX.equalTo(weakSelf.mas_centerX).offset(-60);
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(45, 23));
    }];

}

- (UIImageView *)headBackImage{
    if (!_headBackImage) {
        _headBackImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"我的背景"]];
    }
    return _headBackImage;
    
}

- (UIButton *)loginBtn{
    if (!_loginBtn) {
        _loginBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_loginBtn setTitle:@"登陆" forState:(UIControlStateNormal)];
        _loginBtn.titleLabel.font = [UIFont systemFontOfSize:18.0f];
        _loginBtn.titleLabel.textColor = [UIColor whiteColor];
    }
    return _loginBtn;
    
}


- (UIButton *)landingBtn{
    if (!_landingBtn) {
        _landingBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_landingBtn setTitle:@"注册" forState:(UIControlStateNormal)];
        _landingBtn.titleLabel.font = [UIFont systemFontOfSize:18.0f];
        [_landingBtn addTarget:self action:@selector(pushLandingViewController) forControlEvents:(UIControlEventTouchUpInside)];
        _landingBtn.titleLabel.textColor = [UIColor whiteColor];
    }
    return _landingBtn;
    
}

- (void)pushLandingViewController{
    if (_landingBlock) {
        _landingBlock();
    }
}

@end
